﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy3_1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void btnCalculate_Click(object sender, EventArgs e)
        {
            try
            {
                double x = Convert.ToDouble(txtX.Text.Trim());
                double y = Convert.ToDouble(txtY.Text.Trim());
                double r = Convert.ToDouble(txtR.Text.Trim());

                if (r <= 0)
                {
                    MessageBox.Show("半径必须大于0！", "输入错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtR.Focus(); 
                    return;
                }

                Circle circle = new Circle();
                circle.SetValue(x, y, r);

                txtArea.Text = circle.GetArea().ToString();
                txtPerimeter.Text = circle.GetPerimeter().ToString();
                txtDistance.Text = circle.GetDistance().ToString();
            }
            catch (FormatException)
            {
                MessageBox.Show("请输入有效的数字！", "输入错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
